//
//  PauseGameScreen.m
//  TowerDefence
//
//  Created by K3 on 6/7/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "PauseGameScreen.h"

@implementation PauseGameScreen

-(id)initPauseGameScreenWith:(iCoreGUIController *)_mainGUIController withCurrentLayer:(GameLayer *)_currentLayer{
    self = [super initGameLayerWith:_mainGUIController];
    currentLayer = _currentLayer;
    [self loadResource];
    
    return self;
}

-(void)loadResource {   
    mainBackground = [[CCSprite alloc]initWithFile:BLANK_IMAGE];
    mainBackground.opacity = 80;
    mainBackground.position = ccp(240, 160);
    mainBackground.textureRect = CGRectMake(0, 0, 480, 360);
    mainBackground.color = ccc3(0, 0, 0);
    [self addChild:mainBackground z:0];

    CCLabelTTF *resumGameLabel = [CCLabelTTF labelWithString:@"Resume Game" fontName:FONT_COMIC_BOOK fontSize:22];
    resumGameLabel.color = ccc3(255, 255, 64);
    CCMenuItemLabel *resumeMenuItem = [CCMenuItemLabel itemWithLabel:resumGameLabel target:self selector:@selector(resumeGame)];
    resumeMenuItem.position = ccp(0, 0);
    resumeMenuItem.anchorPoint = ccp(0.5f, 0.5f);
    
    CCLabelTTF *mapMenuGameLabel = [CCLabelTTF labelWithString:@"Map Menu" fontName:FONT_COMIC_BOOK fontSize:22];
    mapMenuGameLabel.color = ccc3(255, 255, 64);
    CCMenuItemLabel *mapMenuItem = [CCMenuItemLabel itemWithLabel:mapMenuGameLabel target:self selector:@selector(backToMapMenuScreen)];
    mapMenuItem.position = ccp(0, 0);
    mapMenuItem.anchorPoint = ccp(0.5f, 0.5f);
    
    CCMenu *pauseMenu = [CCMenu menuWithItems:resumeMenuItem, mapMenuItem, nil];
    [pauseMenu alignItemsVerticallyWithPadding:30.0f];
    [self addChild:pauseMenu];
}

-(void)backToMapMenuScreen {
    [mainGUIController runGameScreen:GAME_SCREEN_SELECT_MAP];
    [self resumeGame];
}

-(void)resumeGame {
    [mainGUIController resumeGame:self];
}

-(void)dealloc {
    NSLog(@"Pause game dealloc");
    [mainBackground stopAllActions];
    [mainBackground removeAllChildrenWithCleanup:YES];
    [mainBackground removeFromParentAndCleanup:YES];
    [mainBackground release];
    
    [self stopAllActions];
    [self removeAllChildrenWithCleanup:YES];
    
    [super dealloc];
}

@end
